<?php
JunctionFileCabinet::using("Junction_Mapping_Association");

/**
 * Hold references from to another mapping across a list of columns.
 *
 * <p>References are associated to a given property.  e.g. an 
 * "emails" property on a User object might reference a second
 * mapped object Email.  Email may relate to User across one or
 * more columns, such as the user's id.
 * <p>This class is used much like the Junction_Mapping_Table
 * class to retrieve data on demand for the user.  Specifically,
 * it facilitates retrieval of complex data types.
 */
class Junction_Mapping_References {
	
	private $_references;
	
	public function __construct() {
		$this->_references = array();
	}
	
	/**
	 * @param String $property
	 * @return boolean
	 */
	public function contains($property) {
		return (isset($this->_references[$property]));
	}
	
	/**
	 * @param String $property
	 * @return Junction_Mapping_Association
	 */
	public function propertyToComplex($property) {
		return $this->_references[$property];
	}
	
	/**
	 * @param String $property
	 * @param Junction_Mapping_Association $ref
	 */
	public function addReference($property, Junction_Mapping_Association $ref) {
		$this->_references[$property] = $ref;
	}
}
?>